home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / docs / hyper / BuffyGuide.lha / BuffyGuide / source / Search.main.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-26  |  3.0 KB  |  104 lines

  1. /* -----------------------------------------------------------
  2.   $VER: main.c 1.0 (20.05.2000)
  3.  
  4.   startup / argument parser for BuffyGuideSearch
  5.  
  6.   (C) Copyright 2000 Matthew J Fletcher - All Rights Reserved.
  7.   amimjf@connectfree.co.uk - www.amimjf.connectfree.co.uk
  8.  ------------------------------------------------------------ */
  9.  
  10. #include <stdio.h>
  11. #include <string.h>
  12. #include <time.h>
  13.  
  14. #include "Search.h" // thats ours
  15.  
  16. // some defults
  17. int CASE =0; // off
  18. int DEBUG =0; // off
  19. int VERBOSE =0; // off
  20.  
  21. clock_t start =0;
  22. clock_t end =0;
  23. float total =0;
  24. long int lines =0;
  25. long int nodes =0;
  26. char searchstring[255];
  27. FILE *guide_fp;
  28. FILE *temp_fp;
  29. long int matchesfound =0;
  30.  
  31. unsigned char *vers = "$VER: BuffyGuideSearch v1.01 - © Matthew J Fletcher";
  32.  
  33. int main(int argc, char *argv[])
  34. { // hello
  35. int x=0,n=0,result=0;
  36.  
  37.     // ----------------------------------
  38.     // first check if we got any arguments
  39.     // ----------------------------------
  40.  
  41.     if (argc >= 1) // we got some
  42.         { // check all arguments for sane options
  43.         do {
  44.            #if defined (_DCC) || defined (__BORLANDC__) || defined (__VBCC__)
  45.            if ( (stricmp(argv[x],"-h") ==0) ||      // they want help
  46.                 (stricmp(argv[x],"--help") ==0) ||  // unix style
  47.                 (stricmp(argv[x],"?") ==0) ||       // amiga style
  48.                 (stricmp(argv[x],"/?") ==0) )       // msdos style
  49.            #else
  50.            if ( (strcasecmp(argv[x],"-h") ==0) ||
  51.                 (strcasecmp(argv[x],"--help") ==0) ||
  52.                 (strcasecmp(argv[x],"?") ==0) ||
  53.                 (strcasecmp(argv[x],"/?") ==0) )
  54.            #endif
  55.               { display_help(argv);
  56.                 exit(0);
  57.               }
  58.  
  59.            #if defined ( _DCC ) || defined ( __BORLANDC__ ) || defined ( __VBCC__ )
  60.            else if (stricmp(argv[x],"-s") ==0) // smart mode
  61.            #else
  62.            else if (strcasecmp(argv[x],"-s") ==0)
  63.            #endif
  64.                     { if (DEBUG ==1)
  65.                       printf("Case Sensitive mode enabled\n");
  66.  
  67.                       CASE = 1;}
  68.  
  69.             #if defined ( _DCC ) || defined ( __BORLANDC__ ) || defined ( __VBCC__ )
  70.             else if (stricmp(argv[x],"-v") ==0) // code extras
  71.             #else
  72.             else if (strcasecmp(argv[x],"-v") ==0)
  73.             #endif
  74.                     { if (DEBUG ==1)
  75.                       printf("Verbose mode enabled\n");
  76.  
  77.                       VERBOSE = 1;}
  78.  
  79.             #if defined ( _DCC ) || defined ( __BORLANDC__ ) || defined ( __VBCC__ )
  80.             else if (stricmp(argv[x],"-d") ==0) // DEBUG mode
  81.             #else
  82.             else if (strcasecmp(argv[x],"-d") ==0)
  83.             #endif
  84.                     { if (DEBUG ==1)
  85.                       printf("Debugging enabled\n");
  86.  
  87.                       DEBUG = 1;}
  88.  
  89.             x++; // next argument
  90.             } while (x != argc); // argv0 is our path
  91.  
  92.         } // end if
  93.  
  94.     // -------------------------------
  95.     // then pop our menu and say hello
  96.     // -------------------------------
  97.  
  98.      do_search(argv);
  99.  
  100.      // internally exits
  101.  
  102. } // end of main
  103.  
  104.